import java.util.Scanner;

class Resource{
	private String str;
    public Resource(String str){
    	setStr(str);
    }
	public Resource() {
		super();
	}
	public String getStr() {
		return str;
	}

	public void setStr(String str) {
		this.str = str;
	}
	public void open(String str) throws Exception{
		String[] st = str.split(" ");
		if(st[0].equals("fail"))
	 	throw new Exception();
	 	
		}
	 	
		public void close() throws RuntimeException{
			String[] st = str.split(" ");
			if(st[1].equals("fail"))throw new RuntimeException();
	 	}
}
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    Resource resource = null;
	    try{
	        resource = new Resource();
	        resource.open(sc.nextLine());
	        System.out.println("resource open success");
	        }catch(Exception e){
	        	System.out.println(e);
	        }finally{
	        	try{resource.close();
	        		System.out.println("resource release success"); 
	        	}catch(RuntimeException e){
	        		System.out.println(e);
	        	}
	        }
	    

	       sc.close();

	}
}
